<?php

if (!defined('PHOX') or !constant('PHOX')) die('Direct access not allowed!');

/**
 * BaseLoader 
 * 
 * @package lib
 * @version 0.1
 * @author Pedro Eugénio <voxmachina@sapo.pt> 
 * @license GPL v.3
 */
class BaseLoader
{
  function __construct() {}

 /**
  * lib 
  * 
  * @param string $class 
  * @return void
  */
  public function lib( $class = '' )
  {
    if( $class == '' ) return false;

    $className  = ucfirst( strtolower( $class ) );
    $pvar       = strtolower( $class );
    
    $ob         =& loaderInstance();
    $ob->$pvar  = register( $class ); 
  }

}

/**
 * Loader 
 * 
 * @uses BaseLoader
 * @package lib
 * @version 0.1
 * @author Pedro Eugénio <voxmachina@sapo.pt> 
 * @license GPL v.3
 */
class Loader extends BaseLoader
{
  public $load;
  private static $instance;

 /**
  * __construct 
  * 
  * @return void
  */
  public function __construct()
  {
    parent::__construct();
    $this->load     = $this;
    self::$instance = $this->load;
  }
 
 /**
  * getInstance 
  * 
  * @return self instance
  */
  public static function getInstance()
  {
    if( !isset( self::$instance ) )
    {
      self::$instance = new self();
    }
    return self::$instance;
  }

}

 /**
  * loaderInstance 
  * 
  * @access public
  * @return void
  */
  function loaderInstance()
  {
    return Loader::getInstance();
  }

?>
